//package org.sunflower.ice;
//
//import com.aliyun.ice20201109.Client;
//import com.aliyun.ice20201109.models.GetMediaProducingJobRequest;
//import com.aliyun.ice20201109.models.GetMediaProducingJobResponse;
//import com.aliyun.ice20201109.models.SubmitMediaProducingJobResponse;
//import org.springframework.beans.factory.ObjectProvider;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.context.properties.EnableConfigurationProperties;
//import org.springframework.stereotype.Component;
//import org.sunflower.ice.infrastructure.AliyunIceException;
//import org.sunflower.ice.infrastructure.config.IceProperties;
//import org.sunflower.ice.infrastructure.strategy.MediaProducingJobStrategy;
//import org.sunflower.ice.infrastructure.MediaProducingJobTypeEnum;
//
//import java.util.List;
//import java.util.Optional;
//import java.util.function.Supplier;
//import java.util.stream.Collectors;
//
///**
// * @description: 阿里云ice
// * @author: TanJingyu
// * @create: 2021-10-11 13:14
// **/
//@Component
//@EnableConfigurationProperties(value = IceProperties.class)
//public class AliyunIceService {
//    private List<MediaProducingJobStrategy> strategies;
//    @Autowired
//    private Client client;
//
//    /**
//     * 提交剪辑合成任务
//     * @param params
//     * @param typeEnum
//     * @param <T>
//     * @return
//     */
//    public <T> SubmitMediaProducingJobResponse submitMediaProducingJob(Supplier<T> params, MediaProducingJobTypeEnum typeEnum) {
//        return screening(typeEnum).orElseThrow(() -> new AliyunIceException("未匹配到合适类型")).submit(params);
//    }
//
//    /**
//     * 获取单个合成任务
//     */
//    public void getMediaProducingJobResult() {
//        MediaProducingJobStrategy strategy = screening(typeEnum).orElseThrow(() -> new AliyunIceException("未匹配到合适类型"));
//
//        GetMediaProducingJobRequest request = new GetMediaProducingJobRequest();
//        request.setJobId("****67f44f4964e6c998dee8****");
//        GetMediaProducingJobResponse reqponse = client.getMediaProducingJob(request);
//        System.out.println("jobId : " + reqponse.getBody().getMediaProducingJob().getJobId());
//        System.out.println("status : " + reqponse.getBody().getMediaProducingJob().getStatus());
//
//    }
//
//    private Optional<MediaProducingJobStrategy> screening(MediaProducingJobTypeEnum typeEnum) {
//        for (MediaProducingJobStrategy strategy : this.strategies) {
//            if (strategy.support(typeEnum)) {
//                return Optional.of(strategy);
//            }
//        }
//
//        return Optional.empty();
//    }
//
//    public AliyunIceService(ObjectProvider<MediaProducingJobStrategy> strategies) {
//        this.strategies = strategies.orderedStream().collect(Collectors.toList());
//    }
//}
